package com.example.utils;

import java.sql.*;

public class DatabaseExample {
    public static void main(String[] args) {
        String url = "jdbc:mysql://39.106.47.147:3306/shixun?serverTimezone=GMT%2B8";
        String username = "root";
        String password = "root";

        try (Connection connection = DriverManager.getConnection(url, username, password)) {
            DatabaseMetaData metadata = connection.getMetaData();
            ResultSet resultSet = metadata.getTables(null, null, null, new String[]{"TABLE"});

            System.out.println("Tables in the database:");
            while (resultSet.next()) {
                String tableName = resultSet.getString("TABLE_NAME");
                System.out.println(tableName);
            }

            resultSet.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}